package com.biyao.service.model.base;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import java.util.HashMap;
import java.util.Map;

import com.biyao.schedulingdao.base.TWorkerTypeMapper;
import com.biyao.schedulingentity.base.TWorkerTypeEntity;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.ArrayList;
/**
 * 
 *
 * @author code generator
 * @date 2019-09-16 09:44:08
 */
@Service
public class TWorkerTypeService extends ServiceImpl<TWorkerTypeMapper, TWorkerTypeEntity>{

    public Page list(int pageNum, int pageSize){

        EntityWrapper<TWorkerTypeEntity> tWorkerTypeentityWrapper=new EntityWrapper<>();
        Page page=selectPage(new Page(pageNum,pageSize),tWorkerTypeentityWrapper);
        page.setRecords(formatRecords(page.getRecords()));
        return page;
    }

    List formatRecords(List<TWorkerTypeEntity> list){
        List resList=new ArrayList();
        for(TWorkerTypeEntity tWorkerTypeEntity:list){
            Map map=formatEntity(tWorkerTypeEntity);
            resList.add(map);
        }
        return resList;
    }

    Map formatEntity(TWorkerTypeEntity tWorkerTypeEntity){
        Map map=new HashMap(16);
        //工种
        if(tWorkerTypeEntity.getId()!=null){
           map.put("id",tWorkerTypeEntity.getId());
        }
        //代号
        if(tWorkerTypeEntity.getCode()!=null){
           map.put("code",tWorkerTypeEntity.getCode());
        }
        //名字
        if(tWorkerTypeEntity.getName()!=null){
           map.put("name",tWorkerTypeEntity.getName());
        }
        //
        if(tWorkerTypeEntity.getRemark()!=null){
           map.put("remark",tWorkerTypeEntity.getRemark());
        }
        //
        if(tWorkerTypeEntity.getCreateTime()!=null){
           map.put("createTime",tWorkerTypeEntity.getCreateTime());
        }
        //
        if(tWorkerTypeEntity.getUpdateTime()!=null){
           map.put("updateTime",tWorkerTypeEntity.getUpdateTime());
        }
        //
        if(tWorkerTypeEntity.getCreateBy()!=null){
           map.put("createBy",tWorkerTypeEntity.getCreateBy());
        }
        //
        if(tWorkerTypeEntity.getUpdateBy()!=null){
           map.put("updateBy",tWorkerTypeEntity.getUpdateBy());
        }
        return map;
    }

}

